package com.hopes.bizz.close.position.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopes.bizz.close.position.dto.HazardCachePositionDTO;
import com.hopes.bizz.close.position.dto.HazardCarDTO;
import com.hopes.bizz.close.position.service.HazardCachePositionService;
import com.hopes.boss.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author yumr
 * @ProjectName bizz
 * @Description 危险品车辆实时定位
 * @time 2024/1/30 14:24
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/hazard/rtPosition" )
@Tag(description = "rtPosition" , name = "危险品车辆实时定位" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HazardRtPositionController {

    private final HazardCachePositionService hazardCachePositionService;


    /**
     * 危险品车辆实时定位
     * @param hazardCachePositionDTO 危险品车辆实时定位
     * @return
     */
    @Operation(summary = "危险品车辆实时定位" , description = "实时定位数据" )
    @PostMapping("/locations" )
    @PreAuthorize("@pms.hasPermission('hazard_rt_position_view')" )
    public R getPlHisPositionList(@RequestBody HazardCachePositionDTO hazardCachePositionDTO) {
        return hazardCachePositionService.locations(hazardCachePositionDTO);
    }

    @Operation(summary = "获取实时危险品车辆定位" , description = "获取实时危险品车辆定位" )
    @GetMapping("/listCache" )
    @PreAuthorize("@pms.hasPermission('hazard_rt_position_view')" )
    public R listHazardCarRtPosition() {
        return R.ok(hazardCachePositionService.listHazardCarCachePosition());
    }

    @Operation(summary = "清空实时危险品车辆定位" , description = "清空实时危险品车辆定位" )
    @GetMapping("/cleanCache" )
    @PreAuthorize("@pms.hasPermission('hazard_rt_position_view')" )
    public R cleanHazardCarRtPosition() {
        return R.ok(hazardCachePositionService.cleanHazardCarCachePosition());
    }

    @Operation(summary = "获取实时危险品车辆定位列表" , description = "获取实时危险品车辆定位列表" )
    @GetMapping("/listOnline" )
    @PreAuthorize("@pms.hasPermission('hazard_rt_position_view')" )
    public R listHazardCarRtPosition(HazardCarDTO hazardCarDTO) {
        return R.ok(hazardCachePositionService.listHazardCarRtPosition(hazardCarDTO));
    }

    @Operation(summary = "分页获取实时危险品车辆定位" , description = "分页获取实时危险品车辆定位" )
    @GetMapping("/pageOnline" )
    @PreAuthorize("@pms.hasPermission('hazard_rt_position_view')" )
    public R pageHazardCarRtPosition(Page page, HazardCarDTO hazardCarDTO) {
        return R.ok(hazardCachePositionService.pageHazardCarRtPosition(page, hazardCarDTO));
    }

    @Operation(summary = "分页获取企业危险品车辆及在线数量" , description = "分页获取企业危险品车辆及在线数量" )
    @GetMapping("/pageTotalOnline" )
    @PreAuthorize("@pms.hasPermission('hazard_rt_position_view')" )
    public R pageTotalOnlineNumber(Page page) {
        return R.ok(hazardCachePositionService.pageTotalOnlineNumber(page));
    }


}
